const http = require('http')
const fs = require('fs')
const path = require('path')

const server = http.createServer()

server.listen(3000, () => {
    console.log('123')
})

server.on('request', ((req, res) => {
    console.log(req.url)
    if (req.url === '/' || req.url === '/index.html') {
        const fullPath = path.join(__dirname, './index.html')
        const resFile = fs.readFileSync(fullPath)
        res.end(resFile)
    } else{
        console.log('err')
    }
}))